#ifndef CLAYOUT_H_
#define CLAYOUT_H_

#include "../math/cmath.h"
#include "../string/cstringutils.h"

// Foward declarations
class CGuiObject;
class CDialog;

/**
 * CLayout - class representing layout of components on dialog
 * @author Michal Rost
 * @date 29.03.2008
 */
class CLayout : public CObject {
  friend class CGuiObject;
  friend class CDialog;
public:
  CLayout();
  CLayout(const vector<unsigned short> &patternSizesX,
      const vector<unsigned short> &patternSizesY,
      unsigned short paddingX = 0, unsigned short paddingY = 0,
      unsigned short spacingX = 0, unsigned short spacingY = 0);
  CLayout(string patternSizesX, string patternSizesY,
      unsigned short paddingX = 0, unsigned short paddingY = 0,
      unsigned short spacingX = 0, unsigned short spacingY = 0);
  static string getClassName() {
    return "CLayout";
  }
protected:
  unsigned short paddingX, paddingY;
  unsigned short spacingX, spacingY;
  vector<unsigned short> patternSizesX, patternSizesY;
  unsigned short getPaddingX() const;
  unsigned short getPaddingY() const;
  unsigned short getSpacingX() const;
  unsigned short getSpacingY() const;
  unsigned short calculateComponentCoordX(TIndex posX);
  unsigned short calculateComponentCoordY(TIndex posY);
  unsigned short calculateComponentWidth(TIndex posX, TIndex spanX);
  unsigned short calculateComponentHeight(TIndex posY, TIndex spanY);
  unsigned short calculateTotalWidth();
  unsigned short calculateTotalHeight();
  unsigned short sumPatternSizes(vector<unsigned short> &v, TIndex begin,
      TIndex end);
  void createPatternSizesFromString(string str, vector<unsigned short> &v);
  void clear();
};

#endif
